Index: moodle/filter/mediaplugin/filter.php
--- moodle/filter/mediaplugin/filter.php Base (1.72)
+++ moodle/filter/mediaplugin/filter.php Locally Modified (Based On 1.72)
@@ -49,61 +49,61 @@
         $newtext = $text; // fullclone is slow and not needed here
 
         if ($CFG->filter_mediaplugin_enable_mp3) {
-            $search = '/<a.*?href="([^<]+\.mp3)"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.mp3)"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_mp3_callback', $newtext);
         }
 
         if ($CFG->filter_mediaplugin_enable_swf) {
-            $search = '/<a.*?href="([^<]+\.swf)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.swf)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_swf_callback', $newtext);
         }
 
         if ($CFG->filter_mediaplugin_enable_flv) {
-            $search = '/<a.*?href="([^<]+\.flv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.flv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_flv_callback', $newtext);
         }
 
         if ($CFG->filter_mediaplugin_enable_mov) {
-            $search = '/<a.*?href="([^<]+\.mov)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.mov)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
 
-            $search = '/<a.*?href="([^<]+\.mp4)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.mp4)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
 
-            $search = '/<a.*?href="([^<]+\.m4v)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.m4v)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
 
-            $search = '/<a.*?href="([^<]+\.m4a)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.m4a)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
         }
 
         if ($CFG->filter_mediaplugin_enable_wmv) {
-            $search = '/<a.*?href="([^<]+\.wmv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.wmv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_wmp_callback', $newtext);
         }
 
         if ($CFG->filter_mediaplugin_enable_mpg) {
-            $search = '/<a.*?href="([^<]+\.mpe?g)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.mpe?g)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
         }
 
         if ($CFG->filter_mediaplugin_enable_avi) {
-            $search = '/<a.*?href="([^<]+\.avi)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.avi)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_wmp_callback', $newtext);
         }
 
         if ($CFG->filter_mediaplugin_enable_ram) {
-            $search = '/<a.*?href="([^<]+\.ram)"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.ram)"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext);
         }
 
         if ($CFG->filter_mediaplugin_enable_rpm) {
-            $search = '/<a.*?href="([^<]+\.rpm)"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.rpm)"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext);
         }
 
         if ($CFG->filter_mediaplugin_enable_rm) {
-            $search = '/<a.*?href="([^<]+\.rm)"[^>]*>.*?<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.rm)"[^>]*>.*?<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext);
         }
 
@@ -118,11 +118,11 @@
         }
 
         if (!empty($CFG->filter_mediaplugin_enable_img)) {
-            $search = '/<a.*?href="([^<]+\.jpg)"[^>]*>(.*?)<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.jpg)"[^>]*>(.*?)<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_img_callback', $newtext);
-            $search = '/<a.*?href="([^<]+\.png)"[^>]*>(.*?)<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.png)"[^>]*>(.*?)<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_img_callback', $newtext);
-            $search = '/<a.*?href="([^<]+\.gif)"[^>]*>(.*?)<\/a>/is';
+            $search = '/<a[^>]*?href="([^<]+\.gif)"[^>]*>(.*?)<\/a>/is';
             $newtext = preg_replace_callback($search, 'filter_mediaplugin_img_callback', $newtext);
         }
 
@@ -155,18 +155,37 @@
 
     $url = addslashes_js($link[1]);
 
-    $args = Array();
-    $args['movie'] = $CFG->wwwroot.'/filter/mediaplugin/mp3player.swf?src='.$url;
-    $args['width'] = 90;
-    $args['height'] = 15;
-    $args['majorversion'] = 6;
-    $args['build'] = 40;
-    $args['flashvars'] = $c;
-    $args['quality'] = 'high';
+    $playerpath = $CFG->wwwroot.'/filter/mediaplugin/mp3player.swf';
+    $colors = explode('&', $c);
+    $playercolors = array();
+    foreach ($colors as $color) {
+        $color = explode('=', $color);
+        $playercolors[$color[0]] = $color[1];
+    }
 
-    $jsoutput = create_ufo_inline($id, $args);
+    $output = <<<OET
+  <span class="mediaplugin mediaplugin_mp3" id="$id"></span>
+  <noscript>
+    <object width="251" height="30" id="nonjsmp3plugin" name="undefined" data="$playerpath" type="application/x-shockwave-flash">
+    <param name="movie" value="$playerpath" />
+    <param name="allowfullscreen" value="false" />
+    <param name="allowscriptaccess" value="always" />
+    <param name="flashvars" value='config={"plugins": {"controls": {
+                                                            "fullscreen": false,
+                                                            "height": 15,
+                                                            "autoHide": false
+                                                            }
+                                                    },
+                                           "clip":{"url":"$url",
+                                                   "autoPlay": false},
+                                           "content":{"url":"$playerpath"}}}' />
+    </object>
+  </noscript>
+OET;
 
-    $output = $link[0].'<span class="mediaplugin mediaplugin_mp3" id="'.$id.'">('.get_string('mp3audio', 'filter_mediaplugin').')</span>'.$jsoutput;
+    $jsoutput = create_flowplayer($id, $url, 'mp3', $playercolors);
+    $output .= $link[0];
+    $output .= $jsoutput;
 
     return $output;
 }
@@ -208,19 +227,25 @@
     $height = empty($link[4]) ? '360' : $link[4];
     $url = addslashes_js($link[1]);
 
-    $args = Array();
-    $args['movie'] = $CFG->wwwroot.'/filter/mediaplugin/flvplayer.swf?file='.$url;
-    $args['width'] = $width;
-    $args['height'] = $height;
-    $args['majorversion'] = 6;
-    $args['build'] = 40;
-    $args['allowscriptaccess'] = 'never';
-    $args['quality'] = 'high';
-    $args['allowfullscreen'] = 'true';
-    $jsoutput = create_ufo_inline($id, $args);
+    $playerpath = $CFG->wwwroot.'/filter/mediaplugin/flvplayer.swf';
 
-    $output = $link[0].'<span class="mediaplugin mediaplugin_flv" id="'.$id.'">('.get_string('flashvideo', 'filter_mediaplugin').')</span>'.$jsoutput;
+    $output = <<<EOT
+    <span class="mediaplugin mediaplugin_flv" id="$id"></span>
+ <noscript>
+    <object width="251" height="200" id="undefined" name="undefined" data="$playerpath" type="application/x-shockwave-flash">
+    <param name="movie" value="$playerpath" />
+    <param name="allowfullscreen" value="true" />
+    <param name="allowscriptaccess" value="always" />
+    <param name="flashvars" value='config={"clip":{"url":"$url",
+                                                   "autoPlay": false},
+                                           "content":{"url":"$playerpath"}}}' />
+    </object>   
+  </noscript>
+EOT;
 
+    $jsoutput = create_flowplayer($id, $url, 'flv');
+    $output .= $link[0];
+    $output .= $jsoutput;
     return $output;
 }
 
Index: moodle/lib/flowplayer.js
--- moodle/lib/flowplayer.js No Base Revision
+++ moodle/lib/flowplayer.js Locally New
@@ -0,0 +1,24 @@
+/*
+ * flowplayer.js 3.2.3. The Flowplayer API
+ *
+ * Copyright 2009 Flowplayer Oy
+ *
+ * This file is part of Flowplayer.
+ *
+ * Flowplayer is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Flowplayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Flowplayer.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Date: 2010-08-10 10:12:09 +0000 (Tue, 10 Aug 2010)
+ * Revision: 539
+ */
+(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.slice(0,q)||"*";var o=s.slice(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).slice(2,10)}var h=function(t,r,s){var q=this,p={},u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.slice(0,v.length-1);var w="onBefore"+v.slice(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(y&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(v)!=-1){i(A,y);if(y.metaData){if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var o=this,s={},u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var z=q._api().fp_getPlugin(p);if(!z){return}i(o,z);delete o.methods;if(!u){m(z.methods,function(){var B=""+this;o[B]=function(){var C=[].slice.call(arguments);var D=q._api().fp_invoke(p,B,C);return D==="undefined"||D===undefined?o:D}});u=true}}var A=s[w];if(A){var y=A.apply(o,v);if(w.slice(0,1)=="_"){delete s[w]}return y}return o}})};function b(q,F,t){var w=this,v=null,C=false,u,s,E=[],y={},x={},D,r,p,B,o,z;i(w,{id:function(){return D},isLoaded:function(){return(v!==null&&v.fp_play!==undefined&&!C)},getParent:function(){return q},hide:function(G){if(G){q.style.height="0px"}if(w.isLoaded()){v.style.height="0px"}return w},show:function(){q.style.height=z+"px";if(w.isLoaded()){v.style.height=o+"px"}return w},isHidden:function(){return w.isLoaded()&&parseInt(v.style.height,10)===0},load:function(I){if(!w.isLoaded()&&w._fireEvent("onBeforeLoad")!==false){var G=function(){u=q.innerHTML;if(u&&!flashembed.isSupported(F.version)){q.innerHTML=""}flashembed(q,F,{config:t});if(I){I.cached=true;j(x,"onLoad",I)}};var H=0;m(a,function(){this.unload(function(J){if(++H==a.length){G()}})})}return w},unload:function(I){if(this.isFullscreen()&&/WebKit/i.test(navigator.userAgent)){if(I){I(false)}return w}if(u.replace(/\s/g,"")!==""){if(w._fireEvent("onBeforeUnload")===false){if(I){I(false)}return w}C=true;try{if(v){v.fp_close();w._fireEvent("onUnload")}}catch(G){}var H=function(){v=null;q.innerHTML=u;C=false;if(I){I(true)}};setTimeout(H,50)}else{if(I){I(false)}}return w},getClip:function(G){if(G===undefined){G=B}return E[G]},getCommonClip:function(){return s},getPlaylist:function(){return E},getPlugin:function(G){var I=y[G];if(!I&&w.isLoaded()){var H=w._api().fp_getPlugin(G);if(H){I=new l(G,H,w);y[G]=I}}return I},getScreen:function(){return w.getPlugin("screen")},getControls:function(){return w.getPlugin("controls")._fireEvent("onUpdate")},getLogo:function(){try{return w.getPlugin("logo")._fireEvent("onUpdate")}catch(G){}},getPlay:function(){return w.getPlugin("play")._fireEvent("onUpdate")},getConfig:function(G){return G?k(t):t},getFlashParams:function(){return F},loadPlugin:function(J,I,L,K){if(typeof L=="function"){K=L;L={}}var H=K?e():"_";w._api().fp_loadPlugin(J,I,L,H);var G={};G[H]=K;var M=new l(J,null,w,G);y[J]=M;return M},getState:function(){return w.isLoaded()?v.fp_getState():-1},play:function(H,G){var I=function(){if(H!==undefined){w._api().fp_play(H,G)}else{w._api().fp_play()}};if(w.isLoaded()){I()}else{if(C){setTimeout(function(){w.play(H,G)},50)}else{w.load(function(){I()})}}return w},getVersion:function(){var H="flowplayer.js 3.2.3";if(w.isLoaded()){var G=v.fp_getVersion();G.push(H);return G}return H},_api:function(){if(!w.isLoaded()){throw"Flowplayer "+w.id()+" not loaded when calling an API method"}return v},setClip:function(G){w.setPlaylist([G]);return w},getIndex:function(){return p}});m(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var G="on"+this;if(G.indexOf("*")!=-1){G=G.slice(0,G.length-1);var H="onBefore"+G.slice(2);w[H]=function(I){j(x,H,I);return w}}w[G]=function(I){j(x,G,I);return w}});m(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","),function(){var G=this;w[G]=function(I,H){if(!w.isLoaded()){return w}var J=null;if(I!==undefined&&H!==undefined){J=v["fp_"+G](I,H)}else{J=(I===undefined)?v["fp_"+G]():v["fp_"+G](I)}return J==="undefined"||J===undefined?w:J}});w._fireEvent=function(P){if(typeof P=="string"){P=[P]}var Q=P[0],N=P[1],L=P[2],K=P[3],J=0;if(t.debug){g(P)}if(!w.isLoaded()&&Q=="onLoad"&&N=="player"){v=v||c(r);o=v.clientHeight;m(E,function(){this._fireEvent("onLoad")});m(y,function(R,S){S._fireEvent("onUpdate")});s._fireEvent("onLoad")}if(Q=="onLoad"&&N!="player"){return}if(Q=="onError"){if(typeof N=="string"||(typeof N=="number"&&typeof L=="number")){N=L;L=K}}if(Q=="onContextMenu"){m(t.contextMenu[N],function(R,S){S.call(w)});return}if(Q=="onPluginEvent"||Q=="onBeforePluginEvent"){var G=N.name||N;var H=y[G];if(H){H._fireEvent("onUpdate",N);return H._fireEvent(L,P.slice(3))}return}if(Q=="onPlaylistReplace"){E=[];var M=0;m(N,function(){E.push(new h(this,M++,w))})}if(Q=="onClipAdd"){if(N.isInStream){return}N=new h(N,L,w);E.splice(L,0,N);for(J=L+1;J<E.length;J++){E[J].index++}}var O=true;if(typeof N=="number"&&N<E.length){B=N;var I=E[N];if(I){O=I._fireEvent(Q,L,K)}if(!I||O!==false){O=s._fireEvent(Q,L,K,I)}}m(x[Q],function(){O=this.call(w,N,L);if(this.cached){x[Q].splice(J,1)}if(O===false){return false}J++});return O};function A(){if($f(q)){$f(q).getParent().innerHTML="";p=$f(q).getIndex();a[p]=w}else{a.push(w);p=a.length-1}z=parseInt(q.style.height,10)||q.clientHeight;D=q.id||"fp"+e();r=F.id||D+"_api";F.id=r;t.playerId=D;if(typeof t=="string"){t={clip:{url:t}}}if(typeof t.clip=="string"){t.clip={url:t.clip}}t.clip=t.clip||{};if(q.getAttribute("href",2)&&!t.clip.url){t.clip.url=q.getAttribute("href",2)}s=new h(t.clip,-1,w);t.playlist=t.playlist||[t.clip];var H=0;m(t.playlist,function(){var J=this;if(typeof J=="object"&&J.length){J={url:""+J}}m(t.clip,function(K,L){if(L!==undefined&&J[K]===undefined&&typeof L!="function"){J[K]=L}});t.playlist[H]=J;J=new h(J,H,w);E.push(J);H++});m(t,function(J,K){if(typeof K=="function"){if(s[J]){s[J](K)}else{j(x,J,K)}delete t[J]}});m(t.plugins,function(J,K){if(K){y[J]=new l(J,K,w)}});if(!t.plugins||t.plugins.controls===undefined){y.controls=new l("controls",null,w)}y.canvas=new l("canvas",null,w);u=q.innerHTML;function I(J){if(/iPad|iPhone/.test(navigator.userAgent)&&!/.flv$/i.test(E[0].url)&&w.ipad===undefined){return true}if(!w.isLoaded()&&w._fireEvent("onBeforeClick")!==false){w.load()}return f(J)}function G(){if(u.replace(/\s/g,"")!==""){if(q.addEventListener){q.addEventListener("click",I,false)}else{if(q.attachEvent){q.attachEvent("onclick",I)}}}else{if(q.addEventListener){q.addEventListener("click",f,false)}w.load()}}setTimeout(G,0)}if(typeof q=="string"){flashembed.domReady(function(){var G=c(q);if(!G){throw"Flowplayer cannot access element: "+q}else{q=G;A()}})}else{A()}}var a=[];function d(o){this.length=o.length;this.each=function(p){m(o,p)};this.size=function(){return o.length}}window.flowplayer=window.$f=function(){var p=null;var o=arguments[0];if(!arguments.length){m(a,function(){if(this.isLoaded()){p=this;return false}});return p||a[0]}if(arguments.length==1){if(typeof o=="number"){return a[o]}else{if(o=="*"){return new d(a)}m(a,function(){if(this.id()==o.id||this.id()==o||this.getParent()==o){p=this;return false}});return p}}if(arguments.length>1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[9,0],expressInstall:"http://static.flowplayer.org/swf/expressinstall.swf",cachebusting:true},t);if(typeof o=="string"){if(o.indexOf(".")!=-1){var s=[];m(n(o),function(){s.push(new b(this,k(t),k(q)))});return new d(s)}else{var r=c(o);return new b(r!==null?r:o,t,q)}}else{if(o){return new b(o,t,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.fn.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var h=document.all,j="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",e=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,b={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function i(m,l){if(l){for(var f in l){if(l.hasOwnProperty(f)){m[f]=l[f]}}}return m}function a(f,n){var m=[];for(var l in f){if(f.hasOwnProperty(l)){m[l]=n(f[l])}}return m}window.flashembed=function(f,m,l){if(typeof f=="string"){f=document.getElementById(f.replace("#",""))}if(!f){return}if(typeof m=="string"){m={src:m}}return new d(f,i(i({},b),m),l)};var g=i(window.flashembed,{conf:b,getVersion:function(){var f;try{f=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(n){try{var l=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");f=l&&l.GetVariable("$version")}catch(m){}}f=e.exec(f);return f?[f[1],f[3]]:[0,0]},asString:function(l){if(l===null||l===undefined){return null}var f=typeof l;if(f=="object"&&l.push){f="array"}switch(f){case"string":l=l.replace(new RegExp('(["\\\\])',"g"),"\\$1");l=l.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+l+'"';case"array":return"["+a(l,function(o){return g.asString(o)}).join(",")+"]";case"function":return'"function()"';case"object":var m=[];for(var n in l){if(l.hasOwnProperty(n)){m.push('"'+n+'":'+g.asString(l[n]))}}return"{"+m.join(",")+"}"}return String(l).replace(/\s/g," ").replace(/\'/g,'"')},getHTML:function(o,l){o=i({},o);var n='<object width="'+o.width+'" height="'+o.height+'" id="'+o.id+'" name="'+o.id+'"';if(o.cachebusting){o.src+=((o.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(o.w3c||!h){n+=' data="'+o.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(o.w3c||h){n+='<param name="movie" value="'+o.src+'" />'}o.width=o.height=o.id=o.w3c=o.src=null;o.onFail=o.version=o.expressInstall=null;for(var m in o){if(o[m]){n+='<param name="'+m+'" value="'+o[m]+'" />'}}var p="";if(l){for(var f in l){if(l[f]){var q=l[f];p+=f+"="+(/function|object/.test(typeof q)?g.asString(q):q)+"&"}}p=p.slice(0,-1);n+='<param name="flashvars" value=\''+p+"' />"}n+="</object>";return n},isSupported:function(f){return k[0]>f[0]||k[0]==f[0]&&k[1]>=f[1]}});var k=g.getVersion();function d(f,n,m){if(g.isSupported(n.version)){f.innerHTML=g.getHTML(n,m)}else{if(n.expressInstall&&g.isSupported([6,65])){f.innerHTML=g.getHTML(i(n,{src:n.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title})}else{if(!f.innerHTML.replace(/\s/g,"")){f.innerHTML="<h2>Flash version "+n.version+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(f.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+j+"'>here</a></p>");if(f.tagName=="A"){f.onclick=function(){location.href=j}}}if(n.onFail){var l=n.onFail.call(this);if(typeof l=="string"){f.innerHTML=l}}}}if(h){window[n.id]=document.getElementById(n.id)}i(this,{getRoot:function(){return f},getOptions:function(){return n},getConf:function(){return m},getApi:function(){return f.firstChild}})}if(c){jQuery.tools=jQuery.tools||{version:"3.2.3"};jQuery.tools.flashembed={conf:b};jQuery.fn.flashembed=function(l,f){return this.each(function(){$(this).data("flashembed",flashembed(this,l,f))})}}})();

Index: moodle/lib/javascript-static.js
--- moodle/lib/javascript-static.js Base (1.163)
+++ moodle/lib/javascript-static.js Locally Modified (Based On 1.163)
@@ -1502,3 +1502,69 @@
         smartselect.init(Y, id, options, {select:select});
     });
 }
+
+M.util.init_flvflowplayer = function (id, playerpath, fileurl) {// alert (fileurl);
+    $f(id, playerpath, {
+        clip: {
+            url: fileurl,
+            autoPlay: false,
+            autoBuffering: true
+        }
+    });
+}
+
+M.util.init_mp3flowplayer = function (id, playerpath, audioplayerpath, fileurl, color) {
+
+    $f(id, playerpath, {
+
+            // fullscreen button not needed here
+            plugins: {
+                    controls: {
+                            fullscreen: false,
+                            height: 30,
+                            autoHide: false,
+                            background: '#'+color['bgColour'],
+                            buttonColor: '#'+color['btnColour'],
+                            sliderColor: '#'+color['handleColour'],
+                            volumeSliderColor: '#'+color['handleColour'],
+                            volumeColor: '#'+color['trackColour'],
+                            durationColor: '#'+color['fontColour'],
+                            buttonOverColor: '#'+color['iconOverColour'],
+                            progressColor: '#'+color['handleColour']
+                    },
+                    audio: {url: audioplayerpath}
+            },
+            clip: { url: fileurl,
+                    provider: "audio",
+                    autoPlay: false
+            }
+    });
+}
+
+M.util.init_mp3flowplayerplugin = function (id, playerpath, audioplayerpath, fileurl, color) {
+
+    $f(id, playerpath, {
+            // fullscreen button not needed here
+            plugins: {
+                    controls: {
+                            all: false,
+                            play: true,
+                            scrubber: true,
+                            autoHide: false,
+                            height: 15,
+                            background: '#'+color['bgColour'],
+                            buttonColor: '#'+color['btnColour'],
+                            sliderColor: '#'+color['handleColour'],
+                            volumeSliderColor: '#'+color['handleColour'],
+                            progressColor: '#'+color['handleColour'],
+                            volumeColor: '#'+color['trackColour'],
+                            buttonOverColor: '#'+color['iconOverColour'],
+                    },
+                    audio: {url: audioplayerpath}
+            },
+            clip: { url: fileurl,
+                    provider: "audio",
+                    autoPlay: false
+            }
+    });
+}
Index: moodle/lib/resourcelib.php
--- moodle/lib/resourcelib.php Base (1.13)
+++ moodle/lib/resourcelib.php Locally Modified (Based On 1.13)
@@ -182,36 +182,43 @@
     global $CFG, $OUTPUT, $PAGE;
 
     $c = $OUTPUT->resource_mp3player_colors();   // You can set this up in your theme/xxx/config.php
+    $colors = explode('&', $c);
+    $playercolors = array();
+    foreach ($colors as $color) {
+        $color = explode('=', $color);
+        $playercolors[$color[0]] = $color[1];
+    }
 
-    $c .= '&volText='.get_string('vol', 'resource').'&panText='.get_string('pan','resource');
     $id = 'filter_mp3_'.time(); //we need something unique because it might be stored in text cache
 
-    $ufoargs = array('movie'        => $CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.urlencode($fullurl),
-                     'width'        => 600,
-                     'height'       => 70,
-                     'majorversion' => 6,
-                     'build'        => 40,
-                     'flashvars'    => $c,
-                     'quality'      => 'high');
+    $playerpath = $CFG->wwwroot .'/lib/mp3player/mp3player.swf';
+    $audioplayerpath = $CFG->wwwroot .'/lib/mp3player/flowplayer.audio.swf';
 
-    // If we have Javascript, use UFO to embed the MP3 player, otherwise depend on plugins
     $code = <<<OET
 <div class="resourcecontent resourcemp3">
-  <span class="mediaplugin mediaplugin_mp3" id="$id"></span>
+  <span class="resourcemediaplugin resourcemediaplugin_mp3" id="$id"></span>
   <noscript>
-    <object type="audio/mpeg" data="$fullurl" width="600" height="70">
-      <param name="src" value="$fullurl" />
-      <param name="quality" value="high" />
-      <param name="autoplay" value="true" />
-      <param name="autostart" value="true" />
+    <object width="251" height="30" id="nonjsmp3plugin" name="undefined" data="$playerpath" type="application/x-shockwave-flash">
+    <param name="movie" value="$playerpath" />
+    <param name="allowfullscreen" value="false" />
+    <param name="allowscriptaccess" value="always" />
+    <param name="flashvars" value='config={"plugins": {"controls": {
+                                                            "fullscreen": false,
+                                                            "height": 30,
+                                                            "autoHide": false
+                                                            }
+                                                      },
+                                           "clip":{"url":"$fullurl",
+                                                   "autoPlay": false},
+                                           "content":{"url":"$playerpath"}}}' />
     </object>
     $clicktoopen
   </noscript>
 </div>
 OET;
+    $PAGE->requires->js('/lib/flowplayer.js');
+    $code .= $PAGE->requires->js_function_call('M.util.init_mp3flowplayer', array('id'=>$id, 'playerpath'=>$playerpath, 'audioplayerpath'=>$audioplayerpath, 'fileurl'=>$fullurl, 'color'=>$playercolors));
 
-    $PAGE->requires->js('/lib/ufo.js');
-    $code .= $PAGE->requires->js_function_call('M.util.create_UFO_object', array($id, $ufoargs));
     return $code;
 }
 
@@ -227,34 +234,27 @@
 
     $id = 'filter_flv_'.time(); //we need something unique because it might be stored in text cache
 
-    $ufoargs = array('movie'             => $CFG->wwwroot.'/filter/mediaplugin/flvplayer.swf?file='.urlencode($fullurl),
-                     'width'             => 600,
-                     'height'            => 400,
-                     'majorversion'      => 6,
-                     'build'             => 40,
-                     'allowscriptaccess' => 'never',
-                     'allowfullscreen'   => 'true',
-                     'quality'           => 'high');
+    $playerpath = $CFG->wwwroot .'/filter/mediaplugin/flvplayer.swf';
 
-    // If we have Javascript, use UFO to embed the FLV player, otherwise depend on plugins
-
     $code = <<<EOT
 <div class="resourcecontent resourceflv">
   <span class="mediaplugin mediaplugin_flv" id="$id"></span>
   <noscript>
-    <object type="video/x-flv" data="$fullurl" width="600" height="400">
-      <param name="src" value="$fullurl" />
-      <param name="quality" value="high" />
-      <param name="autoplay" value="true" />
-      <param name="autostart" value="true" />
+    <object width="251" height="200" id="undefined" name="undefined" data="$playerpath" type="application/x-shockwave-flash">
+    <param name="movie" value="$playerpath" />
+    <param name="allowfullscreen" value="true" />
+    <param name="allowscriptaccess" value="always" />
+    <param name="flashvars" value='config={"clip":{"url":"$fullurl",
+                                                   "autoPlay": false},
+                                           "content":{"url":"$playerpath"}}}' />
     </object>
     $clicktoopen
   </noscript>
 </div>
 EOT;
 
-    $PAGE->requires->js('/lib/ufo.js');
-    $code .= $PAGE->requires->js_function_call('M.util.create_UFO_object', array($id, $ufoargs));
+    $PAGE->requires->js('/lib/flowplayer.js');
+    $code .= $PAGE->requires->js_function_call('M.util.init_flvflowplayer', array('id'=>$id, 'playerpath'=>$playerpath, 'fileurl'=>$fullurl));
     return $code;
 }
 
Index: moodle/lib/weblib.php
--- moodle/lib/weblib.php Base (1.1446)
+++ moodle/lib/weblib.php Locally Modified (Based On 1.1446)
@@ -3365,3 +3390,19 @@
     $jsoutput .= html_writer::script(js_writer::function_call('M.util.create_UFO_object', array($id, $args)));
     return $jsoutput;
 }
+
+function create_flowplayer($id, $fileurl, $type='flv', $color='#000000') {
+    global $CFG;
+
+    $playerpath = $CFG->wwwroot.'/filter/mediaplugin/'.$type.'player.swf';
+    $jsoutput = html_writer::script('', $CFG->wwwroot.'/lib/flowplayer.js');
+
+    if ($type == 'flv') {
+        $jsoutput .= html_writer::script(js_writer::function_call('M.util.init_flvflowplayer', array($id, $playerpath, $fileurl)));
+    } else if ($type == 'mp3') {
+        $audioplayerpath = $CFG->wwwroot .'/lib/mp3player/flowplayer.audio.swf';
+        $jsoutput .= html_writer::script(js_writer::function_call('M.util.init_mp3flowplayerplugin', array($id, $playerpath, $audioplayerpath, $fileurl, $color)));
+    }
+
+    return $jsoutput;
+}
Index: moodle/mod/resource/styles.css
--- moodle/mod/resource/styles.css Base (1.3)
+++ moodle/mod/resource/styles.css Locally Modified (Based On 1.3)
@@ -1,4 +1,9 @@
 .path-mod-resource .popupnotice {text-align:center;margin:40px;}
 
-.resourcecontent object {height:800px;width:100%;}
+.resourcecontent object {height:600px;width:800px;}
 .resourcecontent.resourcepdf object{height: 800px;width: 100%;}
+
+.resourcecontent .resourcemediaplugin_mp3 object {height:25px;}
+.path-mod-resource .resourcemediaplugin_mp3 {display:block; height: 25px;}
+.resourcecontent.resourcemp3 object#nonjsmp3plugin{height:25px;}
+
Index: moodle/theme/base/style/core.css
--- moodle/theme/base/style/core.css Base (1.63)
+++ moodle/theme/base/style/core.css Locally Modified (Based On 1.63)
@@ -661,3 +666,11 @@
  * IE - Overide for RTL layout
  */
 .ie.dir-rtl .mform .fitem .felement {margin-right:0;text-align:right;float:right;}
+
+/**
+ * Filters
+ */
+ .mediaplugin {display:block;clear:both;margin-top:5px;margin-bottom:5px;}
+.mediaplugin_mp3 {width:100px; height:15px;}
+.mediaplugin_swf,
+.mediaplugin_flv {height:600px;width:800px;}
